<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<title>奖品兑换</title>
	<link href="css/mui.min.css" rel="stylesheet" />
	<link href="iconfont/iconfont.css" rel="stylesheet" />
	<link href="css/calc.css" rel="stylesheet" />
	<link href="css/waitMe.min.css" rel="stylesheet" />
	<link href="css/posapp-update.css" rel="stylesheet" />
	<style>
	* { touch-action: none; }
	</style>
</head>

<body>
	<header id="header" class="mui-bar mui-bar-nav">
		<button class="mui-action-back mui-btn mui-btn-blue mui-btn-link mui-btn-nav mui-pull-left">
			<span class="mui-icon mui-icon-left-nav"></span>返回
		</button>
		<h1 class="mui-title">奖品兑换</h1>
		<!-- <a class="mui-icon iconfont icon-shouyintubiaojiaojieban mui-pull-right" style="color:white ;"></a> -->
	</header>
	<div class="mui-content">
		<div class="mui-input-row">
			<label>兑换码</label>
			<input type="text" placeholder="请输入兑换码" disabled="disabled" id="result"></input>
		</div>
		<div style="margin: 0px 10px;">
			<button id="login" class="mui-btn mui-btn-block mui-btn-primary  mui-confrim">确认</button>
		</div>
	</div>
	<div class="calc-input" id="calc">
		<table border="1px" align="center" class="calc-width" cellpadding="0" cellpadding="0">
			<tr>
				<td><span id="num7" onclick=clik(this.innerText)>7</span></td>
				<td><span id="num8" onclick=clik(this.innerText)>8</span></td>
				<td><span id="num9" onclick=clik(this.innerText)>9</span></td>

			</tr>
			<tr>
				<td><span id="num4" onclick=clik(this.innerText)>4</span></td>
				<td><span id="num5" onclick=clik(this.innerText)>5</span></td>
				<td><span id="num6" onclick=clik(this.innerText)>6</span></td>
			</tr>
			<tr>
				<td><span id="num1" onclick=clik(this.innerText)>1</span></td>
				<td><span id="num2" onclick=clik(this.innerText)>2</span></td>
				<td><span id="num3" onclick=clik(this.innerText)>3</span></td>
			</tr>

			<tr>
				<td><span id="num0" onclick=clik(this.innerText)>0</span></td>
				<td><span class="mui-icon iconfont icon-fanhui" onclick="del()"></span></td>
				<td style="background: #1cd39b;"><span onclick="confrim()"
						style="font-size: 20px; color: #fff;">确认</span></td>
			</tr>
		</table>
	</div>
	<script src="js/mui.min.js"></script>
	<script src="js/jquery.min.js"></script>
	<script src="js/waitMe.min.js"></script>
	<script src="js/common.js"></script>
	<script src="js/menuFlat/menuFlat.min.js"></script>
	<script src="js/setting.js"></script>
	<script type="text/javascript">
		var h = mui(document).common();

		//防止重复按键
		var quit = true;
		var result = document.getElementById("result");

		//输入值
		function clik(num) {
			result.value = result.value + num;
		}

		//结算
		function confrim() {
			if (result.value != "") {
				h.startMask();

				mui.ajax(setting.serverUrl + "/interfaces/prize/confirm", {
					dataType: 'json', //服务器返回json格式数据 
					type: 'post', //HTTP请求类型 
					data: { 
						code: result.value,
						token : sessionStorage.getItem("token") 
					},
					success: function (response) {
						if (response.result) {
							var htype = {
								url: 'exchange-confirm.html?recordId=' + response.data + "&code=" + result.value
							}

							h.forward_wechat(htype);
						} else {
							// mui.toast("<h3>" + response.message + "</h3>");
							alert(response.message);
						}

						h.endMask();
					},
					error: function () {
						h.endMask();
						mui.toast('您的网络出现异常,请稍后再试');
					}
				});
			} else {
				mui.toast('请输入兑换码');
			}
		}

		//退格
		function del() {
			var str = result.value;
			str = str.substr(0, str.length - 1);
			str = (str != "") ? str : "";
			result.value = str;
		}


		//返回
		mui(".mui-pull-left").on('tap', '.mui-icon-left-nav', function (e) {
			var htype = {
				url: 'home.html'
			}
			h.forward_wechat(htype);
		});

		//付款
		mui(".mui-content").on('tap', '.mui-confrim', function (e) {
			confrim();
		});
	</script>
</body>

</html>